/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaPrincipal.java
 *
 * Created on 17/10/2011, 07:43:31
 */

package projetosustentabilidade;

import java.util.ArrayList;
import javax.swing.JOptionPane;
/**
 *
 * @author Diego
 */
public class TelaPrincipal extends javax.swing.JFrame {

    
    /** Creates new form TelaPrincipal */   
    private ArrayList<String> listaContinentes;

    public TelaPrincipal() {
        initComponents();
        listaContinentes = new ArrayList<String>();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jbt_avancar = new javax.swing.JButton();
        jbt_fechar = new javax.swing.JButton();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jchb_oceania = new javax.swing.JCheckBox();
        jchb_americaNorte = new javax.swing.JCheckBox();
        jchb_africa = new javax.swing.JCheckBox();
        jchb_europa = new javax.swing.JCheckBox();
        jchb_asia = new javax.swing.JCheckBox();
        jchb_americaSul = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jbt_avancar.setText("Avançar");
        jbt_avancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbt_avancarActionPerformed(evt);
            }
        });
        getContentPane().add(jbt_avancar, new org.netbeans.lib.awtextra.AbsoluteConstraints(375, 540, 90, -1));

        jbt_fechar.setText("Fechar");
        jbt_fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbt_fecharActionPerformed(evt);
            }
        });
        getContentPane().add(jbt_fechar, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 540, 75, -1));

        jchb_oceania.setContentAreaFilled(false);
        jchb_oceania.setBounds(730, 280, 20, 21);
        jLayeredPane1.add(jchb_oceania, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jchb_americaNorte.setContentAreaFilled(false);
        jchb_americaNorte.setBounds(160, 170, 20, 21);
        jLayeredPane1.add(jchb_americaNorte, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jchb_africa.setContentAreaFilled(false);
        jchb_africa.setBounds(420, 180, 20, 21);
        jLayeredPane1.add(jchb_africa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jchb_europa.setContentAreaFilled(false);
        jchb_europa.setBounds(480, 90, 20, 21);
        jLayeredPane1.add(jchb_europa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jchb_asia.setContentAreaFilled(false);
        jchb_asia.setBounds(670, 40, 20, 21);
        jLayeredPane1.add(jchb_asia, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jchb_americaSul.setContentAreaFilled(false);
        jchb_americaSul.setBounds(270, 280, 20, 21);
        jLayeredPane1.add(jchb_americaSul, javax.swing.JLayeredPane.DEFAULT_LAYER);

        getContentPane().add(jLayeredPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 30, 860, 500));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/projetosustentabilidade/ImagemMundo.jpg"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, 830, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbt_avancarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbt_avancarActionPerformed
        //Mostra a lista de países

        listaContinentes.clear();
        setContinente();
        if(listaContinentes.size()>0){
            ListaPaises telaListaPaises = new ListaPaises(listaContinentes);
            telaListaPaises.setVisible(true);
        }else{
            JOptionPane.showMessageDialog(null, "Selecione pelo menos um continente para seguir para a proxima tela!");
        }
        
    }//GEN-LAST:event_jbt_avancarActionPerformed

    private void jbt_fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbt_fecharActionPerformed
        System.exit(0);
}//GEN-LAST:event_jbt_fecharActionPerformed

    

    //Seta continente dependendo da seleção
    public void setContinente(){
        if(jchb_asia.isSelected()){
            listaContinentes.add("Asia");
        }

        if(jchb_europa.isSelected()){
            listaContinentes.add("Europa");
        }

        if(jchb_oceania.isSelected()){
            listaContinentes.add("Oceania");
        }

        if(jchb_africa.isSelected()){
            listaContinentes.add("Africa");
        }

        if(jchb_americaNorte.isSelected()){
            listaContinentes.add("América do Norte/Central");
        }

        if (jchb_americaSul.isSelected()) {
            listaContinentes.add("América do Sul");
        }

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JButton jbt_avancar;
    private javax.swing.JButton jbt_fechar;
    private javax.swing.JCheckBox jchb_africa;
    private javax.swing.JCheckBox jchb_americaNorte;
    private javax.swing.JCheckBox jchb_americaSul;
    private javax.swing.JCheckBox jchb_asia;
    private javax.swing.JCheckBox jchb_europa;
    private javax.swing.JCheckBox jchb_oceania;
    // End of variables declaration//GEN-END:variables

}
